#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

struct P
{
    string name;
    int cnt;
    double avg;
} parr[105];

int n, tp = 0;

bool mycmp(const P &p1, const P &p2)
{
    if (p1.cnt == p2.cnt)
    {
        return p1.avg > p2.avg;
    }
    return p1.cnt > p2.cnt;
}

int main()
{
    cin >> n;
    while (n--)
    {
        string name;
        cin >> name;
        int t, temp;
        cin >> t;
        temp = t;
        set<int> s;
        while (temp--)
        {
            int input;
            cin >> input;
            s.insert(input);
        }
        double avg = (double)s.size() / t; // 出现次数平均值最小就是重复标签最少的，此时avg最大
        parr[tp].name = name;
        parr[tp].cnt = s.size();
        parr[tp].avg = avg;
        tp++;
    }
    sort(parr, parr + tp, mycmp);
    if (tp >= 3)
    {
        cout << parr[0].name << " " << parr[1].name << " " << parr[2].name;
    }
    else if (tp == 2)
    {
        cout << parr[0].name << " " << parr[1].name << " -";
    }
    else
    {
        cout << parr[0].name << " - -";
    }
    return 0;
}